package com.distributor;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class lv_info_adapter extends BaseAdapter
{

	Activity context;
	String names[];
	String agentInfo[];
	
	public lv_info_adapter(Activity context, String[] names,
			String[] agentInfo) 
	{
		this.context=context;
		this.names=names;
		this.agentInfo=agentInfo;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return names.length;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	
	private class Viewholder
	{
		TextView txtname;
		TextView txtvalue;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Viewholder holder;
		LayoutInflater inflater=context.getLayoutInflater();
		
		if(convertView==null)
		{
			convertView=inflater.inflate(R.layout.lv_info_row, null);
			holder=new Viewholder();
			holder.txtname=(TextView)convertView.findViewById(R.id.txtname);
			holder.txtvalue=(TextView)convertView.findViewById(R.id.txtvalue);
			convertView.setTag(holder);
		}
		else
		{
			holder=(Viewholder)convertView.getTag();
		}
		
		holder.txtname.setText(names[position]);
		holder.txtvalue.setText(agentInfo[position]);
		
		return convertView;
	}

}
